/*** STATS CITED ***/

clear all
set more 1
capture log close
set scheme s2mono

// global TRACK_TYPES z r
global TARGET_TYPES zscore rscore
global EXPRESSION_TYPES rho sig
global FRAME_RELATIVE_TYPES vrel mrel

do "paths.do"
cd "$WORKING"

log using "$LOGFILES/txtr_6.log", replace

use "$WORKING/txtr_2", clear

/************************************************************
ALPHA
XXX% of students are in generic courses (mostly in grades 4-5),
and XXX% are taking multiple math courses (mostly in grades 7-8).
*************************************************************/
gen n_generic = cgcgeneric * cgenrl
gen n_mult = cgmult * cgenrl

tabstat cgenrl n_generic n_mult, by(grade) statistics(sum)
tabstat cgcgeneric cgmult [weight=cgenrl], by(grade)
tabstat cgcgeneric cgmult [weight=cgenrl]

/************************************************************
BETA
summary stats for tracking measures for all grades combined
*************************************************************/

sum trk_zsco_fa trk_zsco_mr [weight=cgenrt]

/************************************************************
GAMMA
The correlations in tracking across the first and last sample
years for school-grade-year cohorts ranges from XX to XX.
*************************************************************/

egen max_year = max(year), by(campus grade)
egen min_year = min(year), by(campus grade)
gen is_max_year = (year == max_year)
gen is_min_year = (year == min_year)

keep if (is_min_year | is_max_year) & (min_year != max_year)
keep is_max_year campus grade year trk_zsco_fa trk_zsco_mr
reshape wide year trk_zsco_fa trk_zsco_mr, i(campus grade) j(is_max_year)

cor trk*

/************************************************************
THETA
The average elementary (middle) school student in our sample
is in a school that realizes XXX% (XXX%) of its potential to
track students across classes. Ranges from XXX% (XXX%) to XXX%
(XXX%) from the 10th to 90th percentiles.
*************************************************************/

use "$WORKING/txtr_2", clear

gen elem = (grade <= 5)
tabstat trk_zsco_mr [weight=cgenrl], by(elem) statistics(mean p5 p10 p90 p95)

/************************************************************
MU
Average class size by quartile
*************************************************************/

use "$WORKING/txtr_2", clear

xtile size = cgclsszavg, nq(4)
tabstat cgclsszavg, by(size)

/************************************************************
XI
Correlation between [district tax base wealth per student]
and [fraction low income]
*************************************************************/

use "$WORKING/txtr_4a.dta", clear

gen funds_per_student = dfvtott0 / denrtot0
tabstat funds_per_student, statistics(p10 p25 p50 p75 p90 p95 p99)

corr funds_per_student cgdisadv
corr funds_per_student cgdisadv [w=cgenrl]

log close




